<?php
define('FPDF_FONTPATH','font/');
require('../fpdf/fpdf.php');
include ("../Model/ModelConexion.php");

class PDF extends FPDF
{
//Page header
function Header()
{
    //Logo
    $this->Image('Una.png',10,8,25);
    //Arial bold 15
    $this->SetFont('Arial','B',15);
    //Move to the right
    $this->Cell(40);
    //Title
  

    $this->Cell(30,30, 'Reporte de Aulas',0,1,'C');
    //Line break
 
}

//Page footer
function Footer()
{
    //Position at 1.5 cm from bottom
    
    $this->SetY(-10);
    //Arial italic 8
    $this->SetFont('Arial','I',10);
    //Page number
    
    $fechayHora = date("d-m-Y");

    $hora=time();
    $this->Cell(275,-5,'Sistema GesAc',0,1,'C');
    $this->Cell(0,-6,'Información obtenida el '.$fechayHora,0,1,'C');
    $this->Cell(0,-6, 'Dado en '.'Nicoya,Guanacaste,Costa Rica',0,1,'C');

}
}
//Instanciation of inherited class

$pdf = new PDF('P','mm','Letter');
$pdf->SetMargins(52,0);

$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);



        
    //Datos de Conexion


      $objeto = new Conexion(); 
      $codigo=$_GET['ciclo'];
     $hay_aulas = $objeto->Consulta("
        SELECT DISTINCT cadetalles.aula as aula
        FROM cadetalles
        WHERE cadetalles.codigoHorario='$codigo'
        ");

      while ($row = mysql_fetch_array($hay_aulas)) 
      {
        $aula=$row['aula'];
        $pdf->Cell(30,5,"Aula",1,1,'C');
        $pdf->Cell(15,5,$aula,1,11,'C');
        
        $por_c_aula = $objeto->Consulta("
        SELECT cadetalles.dia as dia,cadetalles.horaI as h1,cadetalles.horaF as h2
        FROM cadetalles
        WHERE cadetalles.codigoHorario='$codigo'
        AND cadetalles.aula='$aula'
        ");
        $pdf->Cell(30,5,"Ocupada de ",1,11,'C');$pdf->Cell(30,5,"hasta ",1,11,'C');
          while ($row1 = mysql_fetch_array($por_c_aula)) 
          {
            
          
            $pdf->Cell(30,5,$row1['h1'],1,1,'C');

             

            $pdf->Cell(60,5,$row1['h2'],1,2,'C');

          }
      

      }

$pdf->Output();
?>